/* 全局样式重置 - 优化CLS */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 预加载关键字体，减少字体切换导致的布局偏移 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hjp-Ek-_EeA.woff') format('woff');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuGKYAZ9hjp-Ek-_EeA.woff') format('woff');
}

:root {
  --primary-color: #6c63ff;
  --secondary-color: #00d4aa;
  --light-bg: #f8f9ff;
  --text-color: #333333;
  --text-secondary: #666666;
  --card-bg: #ffffff;
  --card-hover: #ffffff;
  --border-color: #e0e0ff;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
  --error-color: #f44336;
  --success-color: #4caf50;
  --background-color-hover: #f5f7ff;
  --background-color-secondary: #f8f9ff;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--light-bg);
  color: var(--text-color);
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(108, 99, 255, 0.03) 0%, transparent 70%);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  /* 禁用文本选择导致的布局偏移 */
  -webkit-tap-highlight-color: transparent;
}

/* 为标题元素设置行高和最小高度，防止内容加载时的布局偏移 */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  margin-bottom: 1rem;
  font-weight: 600;
  /* 设置最小高度，确保未加载内容时也有占位 */
  min-height: 1.2em;
}

/* 为段落设置固定行高，防止内容加载时的布局偏移 */
p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* 优化表单元素，防止交互时的布局偏移 */
input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  /* 防止用户缩放导致的布局偏移 */
  resize: none;
  /* 为表单元素设置固定高度或min-height */
  min-height: 44px;
}

/* 优化链接样式，防止悬停时的布局偏移 */
a {
  text-decoration: none;
  color: var(--primary-color);
  transition: color 0.3s ease, opacity 0.3s ease;
  /* 不使用边框变化导致的布局偏移 */
  border-bottom: 1px solid transparent;
}

a:hover {
  opacity: 0.9;
}

/* 为列表设置固定缩进，防止内容加载时的布局偏移 */
ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

/* 为图片设置固定尺寸占位符，防止CLS */
img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 4px;
  /* 防止图片加载时的布局偏移 */
  display: block;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 通用按钮样式 */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  letter-spacing: 0.3px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 10px rgba(108, 99, 255, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(108, 99, 255, 0.3);
  background-color: #5a50e6;
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-color);
  padding: 12px 20px;
  border-radius: 10px;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background-color: var(--secondary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary[href^="#"]:active,
.btn-secondary[href^="#"].active {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 卡片样式 */
.card {
  background-color: var(--card-bg);
  border-radius: 20px;
  padding: 28px;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 20px;
  transition: transform 0.5s ease;
}

.card:hover .card-img {
  transform: scale(1.03);
}

/* 响应式网格布局 */
.grid {
  display: grid;
  gap: 24px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* 标题样式 */
.section-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 32px;
  text-align: center;
  position: relative;
  color: var(--text-color);
  letter-spacing: -0.3px;
}

.section-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px;
  margin: 16px auto 0;
}

/* 头部导航样式 - 优化CLS */
header {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  /* 设置固定高度，防止导航栏高度变化导致的布局偏移 */
  height: 72px;
  display: flex;
  align-items: center;
}

/* 页脚样式 */
footer {
  background-color: #ffffff;
  padding: 60px 0 40px;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}

/* 英雄区域轮播背景 - 优化CLS */
.hero {
  padding: 100px 0;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 确保英雄区域有固定的最小高度 */
  height: calc(100vh - 72px);
  min-height: 600px;
}

/* 轮播背景容器 - 固定尺寸，防止CLS */
.hero-carousel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  /* 防止容器尺寸变化 */
  overflow: hidden;
}

/* 轮播图片 - 固定宽高比，防止CLS */
.carousel-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  /* 添加背景色占位，防止白屏闪烁 */
  background-color: #e0e0e0;
}

.carousel-image::before {
  content: '';
  display: block;
  padding-bottom: 56.25%; /* 16:9 宽高比 */
}

/* 活动图片 */
.carousel-image.active {
  opacity: 1;
}

/* 英雄内容保持在前景 - 优化CLS */
.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  transition: all 0.5s ease;
  /* 固定尺寸，防止内容加载时布局偏移 */
  min-height: 280px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

/* 英雄内容标题 - 固定尺寸，防止CLS */
.hero-content h1, .hero-content h2 {
  font-size: 2.2rem;
  font-weight: 700;
  color: white;
  /* 设置固定的行高和最小高度 */
  line-height: 1.2;
  min-height: 72px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 防止文本溢出 */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 英雄内容描述 - 固定尺寸，防止CLS */
.hero-content p {
  font-size: 1.1rem;
  color: white;
  /* 设置固定的行高和最小高度 */
  line-height: 1.6;
  min-height: 80px;
  margin-bottom: 0;
  /* 防止文本溢出 */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* 为服务卡片中的图片设置固定宽高比容器，防止CLS */
.service-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 正确的图片容器实现 */
.service-card .img-container {
  width: 100%;
  height: 0;
  padding-bottom: 75%; /* 4:3 宽高比 */
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}

.service-card .img-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 为卡片添加固定高度，防止内容加载时的布局偏移 */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  /* 为卡片内容设置最小高度，确保即使内容未加载也有占位 */
  min-height: 300px;
}

/* AI服务区域样式 - 优化CLS */
#ai-services {
  cursor: pointer;
  transition: all 0.3s ease;
  /* 设置固定尺寸，防止点击时的布局偏移 */
  min-height: 450px;
}

#ai-services:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* AI服务卡片样式 - 优化CLS */
.service-card {
  transition: all 0.3s ease-in-out;
  position: relative;
  overflow: hidden;
  /* 设置固定的最小高度，防止内容加载时的布局偏移 */
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.service-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(108, 99, 255, 0.15);
}

.service-card img {
  transition: transform 0.5s ease;
}

.service-card:hover img {
  transform: scale(1.05);
}

/* 服务卡片标题 - 固定尺寸，防止CLS */
.service-card h3 {
  color: var(--primary-color);
  margin-bottom: 8px;
  font-weight: 600;
  /* 设置固定的行高和最小高度 */
  line-height: 1.3;
  min-height: 50px;
}

/* 服务卡片描述 - 固定尺寸，防止CLS */
.service-card p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-color);
  opacity: 0.9;
  /* 设置固定的最小高度，确保文本加载时有占位 */
  min-height: 80px;
  /* 限制文本行数，防止布局偏移 */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

/* 点击动画效果 */
.services-access-animation {
  animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.98);
    background-color: rgba(108, 99, 255, 0.05);
  }
  100% {
    transform: scale(1);
  }
}

/* 查看更多链接样式 */
.more-link {
  color: var(--primary-color);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  display: inline-block;
}

.more-link:hover {
  color: var(--secondary-color);
  transform: translateX(5px);
}

.more-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.more-link:hover::after {
  transform: scaleX(1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .btn {
    padding: 10px 24px;
    font-size: 14px;
  }
  
  .section-title {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}